
// Copyright (C) 2009-2011 Luca Piccioni
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;

#pragma warning disable 1572, 1573

namespace Derm.OpenGL {

	/// <summary>
	/// Implementation of the OpenGL specification 
	/// </summary>
	public unsafe partial class Wgl : ProcLoader
	{

		/// <summary>
		/// Binding for wglBindTexImageARB function.
		/// </summary>
		/// <param name="hPbuffer">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="iBuffer">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		public static Boolean BindTexImageARB(IntPtr hPbuffer, int iBuffer) {
			Boolean retvalue;
			if      (Delegates.pwglBindTexImageARB != null)
				retvalue = (Delegates.pwglBindTexImageARB(hPbuffer, iBuffer));
			else
				throw new InvalidOperationException("binding point BindTexImageARB cannot be found");
			LogProc("wglBindTexImageARB({0}, {1}) = {2}", hPbuffer, iBuffer, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglChoosePixelFormatARB function.
		/// </summary>
		/// <param name="hdc">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="piAttribIList">
		/// A <see cref="T:System.Int32*"/>.
		/// </param>
		/// <param name="pfAttribFList">
		/// A <see cref="T:System.Single*"/>.
		/// </param>
		/// <param name="nMaxFormats">
		/// A <see cref="T:System.UInt32"/>.
		/// </param>
		/// <param name="piFormats">
		/// A <see cref="T:System.Int32*"/>.
		/// This parameter holds data returned from function.
		/// </param>
		/// <param name="nNumFormats">
		/// A <see cref="T:System.UInt32"/>.
		/// This parameter holds data returned from function.
		/// </param>
		public static Boolean ChoosePixelFormatARB(IntPtr hdc, int[] piAttribIList, Single[] pfAttribFList, UInt32 nMaxFormats, [Out] int[] piFormats, [Out] out UInt32 nNumFormats) {
			Boolean retvalue;
			unsafe {
				fixed (int* fp_piAttribIList = piAttribIList)
				fixed (Single* fp_pfAttribFList = pfAttribFList)
				fixed (int* fp_piFormats = piFormats)
				fixed (UInt32* fp_nNumFormats = &nNumFormats)
				{
					if      (Delegates.pwglChoosePixelFormatARB != null)
						retvalue = (Delegates.pwglChoosePixelFormatARB(hdc, fp_piAttribIList, fp_pfAttribFList, nMaxFormats, fp_piFormats, fp_nNumFormats));
					else
						throw new InvalidOperationException("binding point ChoosePixelFormatARB cannot be found");
				}
			}
			LogProc("wglChoosePixelFormatARB({0}, {1}, {2}, {3}, {4}, {5}) = {6}", hdc, piAttribIList, pfAttribFList, nMaxFormats, piFormats, nNumFormats, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglCreateBufferRegionARB function.
		/// </summary>
		/// <param name="hDC">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="iLayerPlane">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="uType">
		/// A <see cref="T:System.UInt32"/>.
		/// </param>
		public static IntPtr CreateBufferRegionARB(IntPtr hDC, int iLayerPlane, UInt32 uType) {
			IntPtr retvalue;
			if      (Delegates.pwglCreateBufferRegionARB != null)
				retvalue = (Delegates.pwglCreateBufferRegionARB(hDC, iLayerPlane, uType));
			else
				throw new InvalidOperationException("binding point CreateBufferRegionARB cannot be found");
			LogProc("wglCreateBufferRegionARB({0}, {1}, {2}) = {3}", hDC, iLayerPlane, uType, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglCreateContextAttribsARB function.
		/// </summary>
		/// <param name="hDC">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="hShareContext">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="attribList">
		/// A <see cref="T:System.Int32*"/>.
		/// </param>
		public static IntPtr CreateContextAttribsARB(IntPtr hDC, IntPtr hShareContext, int[] attribList) {
			IntPtr retvalue;
			unsafe {
				fixed (int* fp_attribList = attribList)
				{
					if      (Delegates.pwglCreateContextAttribsARB != null)
						retvalue = (Delegates.pwglCreateContextAttribsARB(hDC, hShareContext, fp_attribList));
					else
						throw new InvalidOperationException("binding point CreateContextAttribsARB cannot be found");
				}
			}
			LogProc("wglCreateContextAttribsARB({0}, {1}, {2}) = {3}", hDC, hShareContext, attribList, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglCreatePbufferARB function.
		/// </summary>
		/// <param name="hDC">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="iPixelFormat">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="iWidth">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="iHeight">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="piAttribList">
		/// A <see cref="T:System.Int32*"/>.
		/// </param>
		public static IntPtr CreatePbufferARB(IntPtr hDC, int iPixelFormat, int iWidth, int iHeight, int[] piAttribList) {
			IntPtr retvalue;
			unsafe {
				fixed (int* fp_piAttribList = piAttribList)
				{
					if      (Delegates.pwglCreatePbufferARB != null)
						retvalue = (Delegates.pwglCreatePbufferARB(hDC, iPixelFormat, iWidth, iHeight, fp_piAttribList));
					else
						throw new InvalidOperationException("binding point CreatePbufferARB cannot be found");
				}
			}
			LogProc("wglCreatePbufferARB({0}, {1}, {2}, {3}, {4}) = {5}", hDC, iPixelFormat, iWidth, iHeight, piAttribList, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglDeleteBufferRegionARB function.
		/// </summary>
		/// <param name="hRegion">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		public static void DeleteBufferRegionARB(IntPtr hRegion) {
			if      (Delegates.pwglDeleteBufferRegionARB != null)
				Delegates.pwglDeleteBufferRegionARB(hRegion);
			else
				throw new InvalidOperationException("binding point DeleteBufferRegionARB cannot be found");
			LogProc("wglDeleteBufferRegionARB({0})", hRegion);
		}

		/// <summary>
		/// Binding for wglDestroyPbufferARB function.
		/// </summary>
		/// <param name="hPbuffer">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		public static Boolean DestroyPbufferARB(IntPtr hPbuffer) {
			Boolean retvalue;
			if      (Delegates.pwglDestroyPbufferARB != null)
				retvalue = (Delegates.pwglDestroyPbufferARB(hPbuffer));
			else
				throw new InvalidOperationException("binding point DestroyPbufferARB cannot be found");
			LogProc("wglDestroyPbufferARB({0}) = {1}", hPbuffer, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglGetCurrentReadDCARB function.
		/// </summary>
		public static IntPtr GetCurrentReadDCARB() {
			IntPtr retvalue;
			if      (Delegates.pwglGetCurrentReadDCARB != null)
				retvalue = (Delegates.pwglGetCurrentReadDCARB());
			else
				throw new InvalidOperationException("binding point GetCurrentReadDCARB cannot be found");
			LogProc("wglGetCurrentReadDCARB()");
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglGetExtensionsStringARB function.
		/// </summary>
		/// <param name="hdc">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		public static string GetExtensionsStringARB(IntPtr hdc) {
			string retvalue;
			if      (Delegates.pwglGetExtensionsStringARB != null)
				retvalue = (Delegates.pwglGetExtensionsStringARB(hdc));
			else
				throw new InvalidOperationException("binding point GetExtensionsStringARB cannot be found");
			LogProc("wglGetExtensionsStringARB({0}) = {1}", hdc, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglGetPbufferDCARB function.
		/// </summary>
		/// <param name="hPbuffer">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		public static IntPtr GetPbufferDCARB(IntPtr hPbuffer) {
			IntPtr retvalue;
			if      (Delegates.pwglGetPbufferDCARB != null)
				retvalue = (Delegates.pwglGetPbufferDCARB(hPbuffer));
			else
				throw new InvalidOperationException("binding point GetPbufferDCARB cannot be found");
			LogProc("wglGetPbufferDCARB({0}) = {1}", hPbuffer, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglGetPixelFormatAttribfvARB function.
		/// </summary>
		/// <param name="hdc">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="iPixelFormat">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="iLayerPlane">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="nAttributes">
		/// A <see cref="T:System.UInt32"/>.
		/// </param>
		/// <param name="piAttributes">
		/// A <see cref="T:System.Int32*"/>.
		/// </param>
		/// <param name="pfValues">
		/// A <see cref="T:System.Single*"/>.
		/// This parameter holds data returned from function.
		/// </param>
		public static Boolean GetPixelFormatAttribARB(IntPtr hdc, int iPixelFormat, int iLayerPlane, UInt32 nAttributes, int[] piAttributes, [Out] Single[] pfValues) {
			Boolean retvalue;
			unsafe {
				fixed (int* fp_piAttributes = piAttributes)
				fixed (Single* fp_pfValues = pfValues)
				{
					if      (Delegates.pwglGetPixelFormatAttribfvARB != null)
						retvalue = (Delegates.pwglGetPixelFormatAttribfvARB(hdc, iPixelFormat, iLayerPlane, nAttributes, fp_piAttributes, fp_pfValues));
					else
						throw new InvalidOperationException("binding point GetPixelFormatAttribARB cannot be found");
				}
			}
			LogProc("wglGetPixelFormatAttribfvARB({0}, {1}, {2}, {3}, {4}, {5}) = {6}", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, pfValues, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglGetPixelFormatAttribivARB function.
		/// </summary>
		/// <param name="hdc">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="iPixelFormat">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="iLayerPlane">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="nAttributes">
		/// A <see cref="T:System.UInt32"/>.
		/// </param>
		/// <param name="piAttributes">
		/// A <see cref="T:System.Int32*"/>.
		/// </param>
		/// <param name="piValues">
		/// A <see cref="T:System.Int32*"/>.
		/// This parameter holds data returned from function.
		/// </param>
		public static Boolean GetPixelFormatAttribARB(IntPtr hdc, int iPixelFormat, int iLayerPlane, UInt32 nAttributes, int[] piAttributes, [Out] int[] piValues) {
			Boolean retvalue;
			unsafe {
				fixed (int* fp_piAttributes = piAttributes)
				fixed (int* fp_piValues = piValues)
				{
					if      (Delegates.pwglGetPixelFormatAttribivARB != null)
						retvalue = (Delegates.pwglGetPixelFormatAttribivARB(hdc, iPixelFormat, iLayerPlane, nAttributes, fp_piAttributes, fp_piValues));
					else
						throw new InvalidOperationException("binding point GetPixelFormatAttribARB cannot be found");
				}
			}
			LogProc("wglGetPixelFormatAttribivARB({0}, {1}, {2}, {3}, {4}, {5}) = {6}", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, piValues, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglQueryPbufferARB function.
		/// </summary>
		/// <param name="hPbuffer">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="iAttribute">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="piValue">
		/// A <see cref="T:System.Int32"/>.
		/// This parameter holds data returned from function.
		/// </param>
		public static Boolean QueryPbufferARB(IntPtr hPbuffer, int iAttribute, [Out] out int piValue) {
			Boolean retvalue;
			unsafe {
				fixed (int* fp_piValue = &piValue)
				{
					if      (Delegates.pwglQueryPbufferARB != null)
						retvalue = (Delegates.pwglQueryPbufferARB(hPbuffer, iAttribute, fp_piValue));
					else
						throw new InvalidOperationException("binding point QueryPbufferARB cannot be found");
				}
			}
			LogProc("wglQueryPbufferARB({0}, {1}, {2}) = {3}", hPbuffer, iAttribute, piValue, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglReleasePbufferDCARB function.
		/// </summary>
		/// <param name="hPbuffer">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="hDC">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		public static int ReleasePbufferDCARB(IntPtr hPbuffer, IntPtr hDC) {
			int retvalue;
			if      (Delegates.pwglReleasePbufferDCARB != null)
				retvalue = (Delegates.pwglReleasePbufferDCARB(hPbuffer, hDC));
			else
				throw new InvalidOperationException("binding point ReleasePbufferDCARB cannot be found");
			LogProc("wglReleasePbufferDCARB({0}, {1}) = {2}", hPbuffer, hDC, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglReleaseTexImageARB function.
		/// </summary>
		/// <param name="hPbuffer">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="iBuffer">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		public static Boolean ReleaseTexImageARB(IntPtr hPbuffer, int iBuffer) {
			Boolean retvalue;
			if      (Delegates.pwglReleaseTexImageARB != null)
				retvalue = (Delegates.pwglReleaseTexImageARB(hPbuffer, iBuffer));
			else
				throw new InvalidOperationException("binding point ReleaseTexImageARB cannot be found");
			LogProc("wglReleaseTexImageARB({0}, {1}) = {2}", hPbuffer, iBuffer, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglRestoreBufferRegionARB function.
		/// </summary>
		/// <param name="hRegion">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="x">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="y">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="width">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="height">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="xSrc">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="ySrc">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		public static Boolean RestoreBufferRegionARB(IntPtr hRegion, int x, int y, int width, int height, int xSrc, int ySrc) {
			Boolean retvalue;
			if      (Delegates.pwglRestoreBufferRegionARB != null)
				retvalue = (Delegates.pwglRestoreBufferRegionARB(hRegion, x, y, width, height, xSrc, ySrc));
			else
				throw new InvalidOperationException("binding point RestoreBufferRegionARB cannot be found");
			LogProc("wglRestoreBufferRegionARB({0}, {1}, {2}, {3}, {4}, {5}, {6}) = {7}", hRegion, x, y, width, height, xSrc, ySrc, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglSaveBufferRegionARB function.
		/// </summary>
		/// <param name="hRegion">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="x">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="y">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="width">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		/// <param name="height">
		/// A <see cref="T:System.Int32"/>.
		/// </param>
		public static Boolean SaveBufferRegionARB(IntPtr hRegion, int x, int y, int width, int height) {
			Boolean retvalue;
			if      (Delegates.pwglSaveBufferRegionARB != null)
				retvalue = (Delegates.pwglSaveBufferRegionARB(hRegion, x, y, width, height));
			else
				throw new InvalidOperationException("binding point SaveBufferRegionARB cannot be found");
			LogProc("wglSaveBufferRegionARB({0}, {1}, {2}, {3}, {4}) = {5}", hRegion, x, y, width, height, retvalue);
			return (retvalue);
		}

		/// <summary>
		/// Binding for wglSetPbufferAttribARB function.
		/// </summary>
		/// <param name="hPbuffer">
		/// A <see cref="T:System.IntPtr"/>.
		/// </param>
		/// <param name="piAttribList">
		/// A <see cref="T:System.Int32*"/>.
		/// </param>
		public static Boolean SetPbufferAttribARB(IntPtr hPbuffer, int[] piAttribList) {
			Boolean retvalue;
			unsafe {
				fixed (int* fp_piAttribList = piAttribList)
				{
					if      (Delegates.pwglSetPbufferAttribARB != null)
						retvalue = (Delegates.pwglSetPbufferAttribARB(hPbuffer, fp_piAttribList));
					else
						throw new InvalidOperationException("binding point SetPbufferAttribARB cannot be found");
				}
			}
			LogProc("wglSetPbufferAttribARB({0}, {1}) = {2}", hPbuffer, piAttribList, retvalue);
			return (retvalue);
		}

		internal static partial class Delegates
		{
			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal delegate Boolean wglBindTexImageARB(IntPtr hPbuffer, int iBuffer);
			internal static wglBindTexImageARB pwglBindTexImageARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal unsafe delegate Boolean wglChoosePixelFormatARB(IntPtr hdc, int* piAttribIList, Single* pfAttribFList, UInt32 nMaxFormats, [Out] int* piFormats, [Out] UInt32* nNumFormats);
			internal static wglChoosePixelFormatARB pwglChoosePixelFormatARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal delegate IntPtr wglCreateBufferRegionARB(IntPtr hDC, int iLayerPlane, UInt32 uType);
			internal static wglCreateBufferRegionARB pwglCreateBufferRegionARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal unsafe delegate IntPtr wglCreateContextAttribsARB(IntPtr hDC, IntPtr hShareContext, int* attribList);
			internal static wglCreateContextAttribsARB pwglCreateContextAttribsARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal unsafe delegate IntPtr wglCreatePbufferARB(IntPtr hDC, int iPixelFormat, int iWidth, int iHeight, int* piAttribList);
			internal static wglCreatePbufferARB pwglCreatePbufferARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal delegate void wglDeleteBufferRegionARB(IntPtr hRegion);
			internal static wglDeleteBufferRegionARB pwglDeleteBufferRegionARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal delegate Boolean wglDestroyPbufferARB(IntPtr hPbuffer);
			internal static wglDestroyPbufferARB pwglDestroyPbufferARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal delegate IntPtr wglGetCurrentReadDCARB();
			internal static wglGetCurrentReadDCARB pwglGetCurrentReadDCARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal delegate string wglGetExtensionsStringARB(IntPtr hdc);
			internal static wglGetExtensionsStringARB pwglGetExtensionsStringARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal delegate IntPtr wglGetPbufferDCARB(IntPtr hPbuffer);
			internal static wglGetPbufferDCARB pwglGetPbufferDCARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal unsafe delegate Boolean wglGetPixelFormatAttribfvARB(IntPtr hdc, int iPixelFormat, int iLayerPlane, UInt32 nAttributes, int* piAttributes, [Out] Single* pfValues);
			internal static wglGetPixelFormatAttribfvARB pwglGetPixelFormatAttribfvARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal unsafe delegate Boolean wglGetPixelFormatAttribivARB(IntPtr hdc, int iPixelFormat, int iLayerPlane, UInt32 nAttributes, int* piAttributes, [Out] int* piValues);
			internal static wglGetPixelFormatAttribivARB pwglGetPixelFormatAttribivARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal delegate Boolean wglMakeContextCurrentARB(IntPtr hDrawDC, IntPtr hReadDC, IntPtr hglrc);
			internal static wglMakeContextCurrentARB pwglMakeContextCurrentARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal unsafe delegate Boolean wglQueryPbufferARB(IntPtr hPbuffer, int iAttribute, [Out] int* piValue);
			internal static wglQueryPbufferARB pwglQueryPbufferARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal delegate int wglReleasePbufferDCARB(IntPtr hPbuffer, IntPtr hDC);
			internal static wglReleasePbufferDCARB pwglReleasePbufferDCARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal delegate Boolean wglReleaseTexImageARB(IntPtr hPbuffer, int iBuffer);
			internal static wglReleaseTexImageARB pwglReleaseTexImageARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal delegate Boolean wglRestoreBufferRegionARB(IntPtr hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
			internal static wglRestoreBufferRegionARB pwglRestoreBufferRegionARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal delegate Boolean wglSaveBufferRegionARB(IntPtr hRegion, int x, int y, int width, int height);
			internal static wglSaveBufferRegionARB pwglSaveBufferRegionARB = null;

			[System.Security.SuppressUnmanagedCodeSecurity()]
			internal unsafe delegate Boolean wglSetPbufferAttribARB(IntPtr hPbuffer, int* piAttribList);
			internal static wglSetPbufferAttribARB pwglSetPbufferAttribARB = null;

		}

		internal static partial class Imports
		{
			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglBindTexImageARB", ExactSpelling = true)]
			internal extern static Boolean wglBindTexImageARB(IntPtr hPbuffer, int iBuffer);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglChoosePixelFormatARB", ExactSpelling = true)]
			internal extern static unsafe Boolean wglChoosePixelFormatARB(IntPtr hdc, int* piAttribIList, Single* pfAttribFList, UInt32 nMaxFormats, [Out]int* piFormats, [Out]UInt32 nNumFormats);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglCreateBufferRegionARB", ExactSpelling = true)]
			internal extern static IntPtr wglCreateBufferRegionARB(IntPtr hDC, int iLayerPlane, UInt32 uType);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglCreateContextAttribsARB", ExactSpelling = true)]
			internal extern static unsafe IntPtr wglCreateContextAttribsARB(IntPtr hDC, IntPtr hShareContext, int* attribList);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglCreatePbufferARB", ExactSpelling = true)]
			internal extern static unsafe IntPtr wglCreatePbufferARB(IntPtr hDC, int iPixelFormat, int iWidth, int iHeight, int* piAttribList);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglDeleteBufferRegionARB", ExactSpelling = true)]
			internal extern static void wglDeleteBufferRegionARB(IntPtr hRegion);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglDestroyPbufferARB", ExactSpelling = true)]
			internal extern static Boolean wglDestroyPbufferARB(IntPtr hPbuffer);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglGetCurrentReadDCARB", ExactSpelling = true)]
			internal extern static IntPtr wglGetCurrentReadDCARB();

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglGetExtensionsStringARB", ExactSpelling = true)]
			internal extern static string wglGetExtensionsStringARB(IntPtr hdc);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglGetPbufferDCARB", ExactSpelling = true)]
			internal extern static IntPtr wglGetPbufferDCARB(IntPtr hPbuffer);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglGetPixelFormatAttribfvARB", ExactSpelling = true)]
			internal extern static unsafe Boolean wglGetPixelFormatAttribfvARB(IntPtr hdc, int iPixelFormat, int iLayerPlane, UInt32 nAttributes, int* piAttributes, [Out]Single* pfValues);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglGetPixelFormatAttribivARB", ExactSpelling = true)]
			internal extern static unsafe Boolean wglGetPixelFormatAttribivARB(IntPtr hdc, int iPixelFormat, int iLayerPlane, UInt32 nAttributes, int* piAttributes, [Out]int* piValues);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglMakeContextCurrentARB", ExactSpelling = true)]
			internal extern static Boolean wglMakeContextCurrentARB(IntPtr hDrawDC, IntPtr hReadDC, IntPtr hglrc);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglQueryPbufferARB", ExactSpelling = true)]
			internal extern static unsafe Boolean wglQueryPbufferARB(IntPtr hPbuffer, int iAttribute, [Out]int piValue);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglReleasePbufferDCARB", ExactSpelling = true)]
			internal extern static int wglReleasePbufferDCARB(IntPtr hPbuffer, IntPtr hDC);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglReleaseTexImageARB", ExactSpelling = true)]
			internal extern static Boolean wglReleaseTexImageARB(IntPtr hPbuffer, int iBuffer);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglRestoreBufferRegionARB", ExactSpelling = true)]
			internal extern static Boolean wglRestoreBufferRegionARB(IntPtr hRegion, int x, int y, int width, int height, int xSrc, int ySrc);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglSaveBufferRegionARB", ExactSpelling = true)]
			internal extern static Boolean wglSaveBufferRegionARB(IntPtr hRegion, int x, int y, int width, int height);

			[System.Security.SuppressUnmanagedCodeSecurity()]
			[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglSetPbufferAttribARB", ExactSpelling = true)]
			internal extern static unsafe Boolean wglSetPbufferAttribARB(IntPtr hPbuffer, int* piAttribList);

		}

	}
}
